package com.example.shushiyunsst.fragment.main.home.child.fu_li_pool.sub

import android.os.Bundle
import android.view.View
import com.example.library_common.adapter.JssBaseViewHolder
import com.example.library_common.album.utils.Utils
import com.example.library_common.base.SimpleListFragment
import com.example.library_common.bean.CommonBean
import com.example.shushiyunsst.R
import com.example.shushiyunsst.fragment.main.home.child.fu_li_pool.bean.ShouYiBean
import com.senon.modularapp.util.JssSpannableString
import ikidou.reflect.TypeBuilder
import java.lang.reflect.Type

/**
 * 收益
 * */
class ShouYiFragment :SimpleListFragment<ShouYiBean>() {

    companion object{
        fun newInstance(): ShouYiFragment {
            val args = Bundle()
            val fragment = ShouYiFragment()
            fragment.arguments = args
            return fragment
        }
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        isEnableLoadMore=false
        isAddDividerItemDecoration=false
    }

    override fun initView(view: View) {
        super.initView(view)
        view.setBackgroundResource(R.color.bg_color)
        mHeader.removeAllViews()
        addHeader(R.layout.shou_yi_header_fragment)

        view.findViewById<View>(R.id.mToolbar)
            .setOnClickListener { onBackPressedSupport() }

        mSwipeRefreshLayout.setColorScheme(R.color.nav_bar_bg_color)
        mRecyclerView.overScrollMode=View.OVER_SCROLL_NEVER
        mSwipeRefreshLayout.setProgressBackgroundColor(R.color.colorAccent)
    }

    override fun getItemLayout()= R.layout.shou_yi_fragment

    override fun convertItem(helper: JssBaseViewHolder?, item: ShouYiBean?) {
        val str0="84.0000"
        val str1="您占比0.5062,本期分得红利42.5208USDT"
        val str3="本期福利池周分红总额度为:$str0, 分红时您持有已产出矿石8200.0000枚，" +
                "满足分红条件已产出矿石的总量为: 16200枚，依据加权分红原则，$str1"


        helper?.setText(R.id.mShouYiTitle,item?.shouYiTitle)
            ?.setText(R.id.value,"\$${item?.value}")
            ?.setText(R.id.timePoint,item?.timePoint)
            ?.setText(R.id.struts,
                JssSpannableString(_mActivity,str3)
                    .first(str0).textColor(R.color.PrimaryColor)
                    .first(str1).textColor(R.color.PrimaryColor)
            )

    }

    override fun getListType(): Type {
        return TypeBuilder.newInstance(CommonBean::class.java)
            .beginSubType(List::class.java)
            .addTypeParam(ShouYiBean::class.java).endSubType().build()
    }

    override fun netRequest() {
//        val jsonFromRaw = Utils.getJsonFromRaw(_mActivity, R.raw.fu_li_pool_shou_yi)
//        parseDate(jsonFromRaw)

        val jsonFromRaw =""
        parseDate(jsonFromRaw)
    }
}